﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class TSLO
    { 

        public TSLO()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return; 
            MV = new VLAGPL();
            DataContext = MV;  
            InitializeComponent();  
        }
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (IsLoaded)
                return;
            LOAD();
            base.Window_Loaded(sender, e);
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (dwMaster == null)
            {
                KEY = "".PadRight(12);
                LO = "".PadRight(2);
            }
            else
            {
                KEY = dwMaster["LPLO"].ToString();
                LO = dwMaster["LPLO"].ToString();
            }
        }
        public void LOAD()
        {
            if (TBMain.Rows.Count == 0)
            {
                dwData = TBMain.NewRow();
                dwData["LPMANDANT"] = app.Mandant;
                dwData["LPLO"] = "AND LPLO LIKE '%%'";
                dwData["LPLB"] = "AND LPLB='  '";
                dwData["LPPLATZ"] = "AND LPPLATZ='        '";
                SResult = ((VLAGPL)MV).QueryLAGPL(dwData, -1);
                MergeData(SResult, false);
            }
        }
        public override void LOADBYAUF()
        {
            vwMaster.View.MoveCurrentTo(-1);
            if (ORDERNUM.Length < 2)
                return;
            Locate("KLO", ORDERNUM.Substring(0,2));
        }   
    }
}
